package dao.Impl;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author wfr
 * @description:
 * @date 2019-05-31 15:11
 * @parem BaseDao
 */
public class BaseDao {
    public static final String url="jdbc:mysql://localhost:3306/petdbs";
    public static final String DB_USER="root";
    public static final String DB_PWT="root";
    Connection con;

    public BaseDao() {
        this.con = getConnection();
    }

    public static Connection getConnection(){
        Connection con=null;
        try {
            //加载驱动
            Class.forName("com.mysql.jdbc.Driver");
            con= DriverManager.getConnection(url,DB_USER,DB_PWT);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return con;
    }


}
